package com.aspose.cells;

class zbtm {
   public static DateTime a(DateTime var0, int var1) {
      DateTime var2;
      if (var0.getMonth() != 12) {
         var2 = new DateTime(var0.getYear(), var0.getMonth() + 1, 1);
      } else {
         var2 = new DateTime(var0.getYear() + 1, 1, 1);
      }

      DateTime var3 = var2.addMonths(var1);
      return var3.addDays(-1.0D);
   }

   static double a(double var0, double var2, boolean var4, boolean var5) {
      double var6 = 0.0D;
      if (var0 == 60.0D) {
         ++var0;
         ++var6;
      }

      DateTime var8 = CellsHelper.getDateTimeFromDouble(var0, var5);
      DateTime var9 = CellsHelper.getDateTimeFromDouble(var2, var5);
      boolean var10 = false;
      if (var9.getDay() == 29 && var9.getMonth() == 2 && DateTime.a(var9.getYear())) {
         var10 = true;
      }

      int var11 = var9.getYear() - var8.getYear();
      var9 = var9.addYears(var8.getYear() - var9.getYear());
      if (com.aspose.cells.a.c.zk.d(var9, var8)) {
         var9 = var9.addYears(1);
         var6 += (double)(360 * (var11 - 1));
         if (var10) {
            ++var6;
         }
      } else {
         var6 += (double)(360 * var11);
         if (var10 && !DateTime.a(var9.getYear())) {
            ++var6;
         }
      }

      if (var9.getYear() > var8.getYear()) {
         var6 += (double)((var9.getMonth() - 1) * 30);
         var6 += (double)var9.getDay();
         if (var9.getDay() == 31) {
            if (!var4) {
               if (var8.getDay() == 30 || var8.getDay() == 31) {
                  --var6;
               }
            } else {
               --var6;
            }
         }

         var6 += (double)((13 - var8.getMonth()) * 30 - var8.getDay());
         if (var8.getDay() == 31) {
            ++var6;
         }
      } else {
         var6 += (double)((var9.getMonth() - var8.getMonth()) * 30 + var9.getDay() - var8.getDay());
         switch(var8.getDay()) {
         case 28:
            if (!var4 && var8.getMonth() == 2 && var8.getYear() != 1900 && !DateTime.a(var8.getYear())) {
               var6 -= 2.0D;
            }
            break;
         case 29:
            if (!var4 && var8.getMonth() == 2 && DateTime.a(var8.getYear())) {
               --var6;
            }
         case 30:
         default:
            break;
         case 31:
            ++var6;
         }

         if (var9.getDay() == 31) {
            if (!var4) {
               if (var8.getDay() == 30 || var8.getDay() == 31) {
                  --var6;
               }
            } else {
               --var6;
            }
         }
      }

      return var6;
   }

   static double a(double var0, double var2, boolean var4) {
      DateTime var5 = CellsHelper.getDateTimeFromDouble(var0, var4);
      DateTime var6 = CellsHelper.getDateTimeFromDouble(var2, var4);
      int var7 = var5.getYear();
      int var8 = var6.getYear();
      boolean var9 = true;
      int var10;
      if (var9) {
         var10 = var8 - var7 + 1;
         var5 = new DateTime(var7, 1, 1);
         var6 = new DateTime(var8 + 1, 1, 1);
         com.aspose.cells.b.a.zk var14 = com.aspose.cells.a.c.zk.e(var6, var5);
         int var15 = (int)var14.c();
         return (double)var15 / (double)var10;
      } else {
         var10 = var8 - var7;
         DateTime var11 = new DateTime(var8, var5.getMonth(), var5.getDay());
         com.aspose.cells.b.a.zk var12 = com.aspose.cells.a.c.zk.e(var11, var5);
         int var13 = (int)var12.c() + 1;
         return (double)var13 / (double)var10;
      }
   }
}
